import {RouteRecordRaw} from 'vue-router';
import {Layout} from '@/router/constant';
import {GameController} from '@vicons/ionicons5';
import {renderIcon} from '@/utils/index';

const routeName = 'game';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/game',
    name: routeName,
    redirect: '/game/gameList',
    component: Layout,
    meta: {
      title: '游戏设置',
      icon: renderIcon(GameController),
      permissions: ['game_gameList', 'game_redEnvelopeSwitch'],
      sort: 2,
    },
    children: [
      {
        path: 'gameList',
        name: `${routeName}_gameList`,
        meta: {
          title: '游戏管理',
          permissions: ['game_gameList'],
          keepAlive: false,
        },
        component: () => import('@/views/game/gameList/gameList.vue'),
      },
      {
        path: 'subpackage',
        name: `${routeName}_subpackage`,
        meta: {
          title: '壳包管理',
          keepAlive: false,
          permissions: ['game_subpackage'],
        },
        component: () => import('@/views/game/subpackage/subpackage.vue'),
      },
      {
        path: 'chanManage',
        name: `${routeName}_chanManage`,
        meta: {
          title: '渠道管理',
          permissions: ['player_chanManage'],
        },
        component: () => import('@/views/game/chanManage/chanManage.vue'),
      },
      {
        path: 'gameAnchor',
        name: `${routeName}_gameAnchor`,
        meta: {
          title: '渠道管理',
          permissions: ['game_gameAnchor'],
        },
        component: () => import('@/views/game/gameAnchor/gameAnchor.vue'),
      },
    ],
  },
];

export default routes;
